package com.imooc.controller;

import com.imooc.entity.User;
import com.imooc.repeatsubmit.RepeatSubmit;
import com.imooc.result.ApiResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户
 *
 * @author imooc
 * @author 2022-12-09
 */
@RestController
@RequestMapping("/user")
public class UserController {

    /**
     * 测试redisson防止表单重复提交
     * 自定义token
     * http://localhost:8080/user/get
     *
     * @return {@link ApiResult}
     * @author imooc
     * @date 2022-12-09
     */
    @RepeatSubmit(lockTime = 10)
    @GetMapping("/get")
    public ApiResult<?> saveUser() {
        User u = new User();
        u.setName("test");
        u.setAge(12);
        return ApiResult.ok(u);
    }

}
